<div class="findtrs">
	<div class="ftitle">
		<div class="lt">
			<h2>充值记录</h2>
		</div>
	</div>

	<div class="funaduibi fbai qmbox1 qmbox2">
		<div class="form">
			<form action="" method="post">
				<ul class="clearfix">
					<li>
						<label>时间</label>
						<div class="bt">
							<input class="t1 t2" type="text" id="stime" value="" placeholder="开始日期"/>
							<span><img src="__STATIC__/lib/index/images/qm18.png" ></span>
							<input class="t1 t2" type="text" id="ltime" value="" placeholder="结束日期"/>
						</div>
					</li>
					<li>
						<label>充值状态</label>
						<select name="status" id="status" class="lsele">
								<option value="">请选择充值状态</option>
								<option value="0">审核中</option>
								<option value="2">未到账</option>
								<option value="1">已到账</option>
						</select>
					</li>
					<li>
						<label>类型</label>
						<select class="lsele" name="type" id="type">
							<option value="">请选择类型</option>
							<option value="0">充值</option>
							<option value="1">退款</option>
						</select>
					</li>
					<li>
						<label>描述</label>
						<input class="t1" type="text" value="" name="desc" id="desc" placeholder="请填写描述"/>
					</li>
					<li>
						<div class="btn">
<!--							<a href="#" class="b1"><span>清空</span></a>-->
							<a href="#" class="b1 on" lay-submit lay-filter="*"><span>查询</span></a>
						</div>
					</li>
				</ul>
			</form>
		</div>
	</div>

	<div class="funaduibi fbai">
		<div class="fdbtable qmfdbtable ftable fboxbai">
			<table border="0" cellspacing="0" cellpadding="0" width="100%" id="dataTable">
			</table>
		</div>
	</div>

</div>

<script type="text/javascript">
	layui.use(['form', 'laydate', 'table',], function(){
		var laydate = layui.laydate,
			form = layui.form,
			table = layui.table; //表格

		//执行一个laydate实例
		laydate.render({
			elem: '#stime' //指定元素
		});
		laydate.render({
			elem: '#ltime' //指定元素
		});

		table.render({
			elem: '#dataTable',
			height: 'auto',
			cellMinWidth: '80',
			totalRow: true,
			method: 'post',
			url: "{:url('fund/log')}",
			id: 'dataTable',
			error: function(){
				setTimeout("window.location.href='" + "{:url('index/index')}" + "'; ", 1000);
			},
			// toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
			// defaultToolbar: ['filter', 'exports'],
			text:{none: '无数据'},
			cols: [[
				{ type: 'numbers'},
				{ field: 'ctime',align: 'center', title: '提交时间', width: 180,
					templet: function (d) {
						return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
					}
				},
				{ field: 'utime',align: 'center', title: '审核时间', width: 180,
					templet: function (d) {
						const utime = d.utime;
						if(utime == undefined){
							return '--';
						}else{
							return layui.util.toDateString(d.utime * 1000, "yyyy-MM-dd HH:mm:ss");
						}
					}
				},
				{ field: '', align: 'left', title: '类型' , width: 100,
					templet: function (d) {
						const type_name = d.type;
						if(type_name == 1){
							return '<font color="red">退款</font>';
						}else{
							return '<font color="green">充值</font>';
						}
					}
				},
				{ field: 'amount',  align: 'right', title: '金额($)',width: 180,
					templet: function (d) {
						return '<span style="float: right;color:#FF5722;font-weight:bold">' + d.amount + '</span>';
					},totalRow: true},
				{ field: 'desc',  align: 'left', title: '描述' },
				{ field: 'remark',  align: 'left', title: '失败原因' },
				{ field: '111',  align: 'left', title: '转账凭证' },
				{ field: '', align: 'left', title: '充值状态' , width: 120,
					templet: function (d) {
						const check_status = d.check_status;
						if(check_status == 2){
							return '<font color="red">失败</font>';
						}else if(check_status == 1){
							return '<font color="green">已到账</font>';
						}else{
							return '<font color="#8c8c8c">审核中</font>';
						}
					}
				},
			]],
			page: true,
			limit: 10,
			limits: [10, 50, 100],
		});
		form.on('submit(*)', function (data) {
			console.log(data.field);
			layui.table.reload('dataTable', {
				// where: data.field
				where: {status:$("#status").val(),
						type:$("#type").val(),
						stime:$("#stime").val(),
						ltime:$("#ltime").val(),
						desc:$("#desc").val(),
				}
				, page: {
					curr: 1 //重新从第 1 页开始
				}
			});
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
	});
</script>